package com.ruoyi.project.poem.goodsbanner.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.framework.aspectj.lang.annotation.DataSource;
import com.ruoyi.framework.aspectj.lang.enums.DataSourceType;
import com.ruoyi.project.poem.goodsbanner.domain.GoodsBanner;
import com.ruoyi.project.poem.goodsbanner.mapper.GoodsBannerMapper;
import com.ruoyi.project.poem.goodsbanner.service.IGoodsBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 首页bannerService业务层处理
 *
 * @author shixiangwen
 * @date 2021-06-24
 */
@Service
@DataSource(DataSourceType.POEM)
public class GoodsBannerServiceImpl implements IGoodsBannerService {
    @Autowired
    private GoodsBannerMapper goodsBannerMapper;

    /**
     * 查询首页banner
     *
     * @param id 首页bannerID
     * @return 首页banner
     */
    @Override
    public GoodsBanner selectGoodsBannerById(Long id) {
        return goodsBannerMapper.selectGoodsBannerById(id);
    }

    /**
     * 查询首页banner列表
     *
     * @param goodsBanner 首页banner
     * @return 首页banner
     */
    @Override
    public List<GoodsBanner> selectGoodsBannerList(GoodsBanner goodsBanner) {
        return goodsBannerMapper.selectGoodsBannerList(goodsBanner);
    }

    /**
     * 新增首页banner
     *
     * @param goodsBanner 首页banner
     * @return 结果
     */
    @Override
    public int insertGoodsBanner(GoodsBanner goodsBanner) {
        goodsBanner.setCreateTime(DateUtils.getNowDate());
        goodsBanner.setCreateUser(ShiroUtils.getLoginName());
        goodsBanner.setStatus(0);
        return goodsBannerMapper.insertGoodsBanner(goodsBanner);
    }

    /**
     * 修改首页banner
     *
     * @param goodsBanner 首页banner
     * @return 结果
     */
    @Override
    public int updateGoodsBanner(GoodsBanner goodsBanner) {
        goodsBanner.setUpdateTime(DateUtils.getNowDate());
        return goodsBannerMapper.updateGoodsBanner(goodsBanner);
    }

    /**
     * 删除首页banner对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteGoodsBannerByIds(String ids) {
        return goodsBannerMapper.deleteGoodsBannerByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除首页banner信息
     *
     * @param id 首页bannerID
     * @return 结果
     */
    @Override
    public int deleteGoodsBannerById(Long id) {
        return goodsBannerMapper.deleteGoodsBannerById(id);
    }
}
